﻿using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Serialization;

namespace ProjectTW.Foliage
{
    public class FoliageSector : SectorBase
    {
        public List<FoliageChunk> FoliageChunks = new List<FoliageChunk>();

        protected override void OnChunkCreated(ChunkBase chunkBase)
        {
            base.OnChunkCreated(chunkBase);
            
            FoliageChunk foliageChunk = chunkBase as FoliageChunk;

            if (foliageChunk != null)
            {
                FoliageChunks.Add(foliageChunk);
            }
        }

        protected override void OnStartCreatingChunks()
        {
            base.OnStartCreatingChunks();

            for (int i = 0; i < FoliageChunks.Count; i++)
            {
                if (FoliageChunks[i] != null)
                {
                    DestroyImmediate(FoliageChunks[i]);
                }
            }

            FoliageChunks.Clear();
        }
    }
}
